package cn.edu.neusoft.wuguangsheng.flowerimpression.activity;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import cn.edu.neusoft.wuguangsheng.flowerimpression.R;
import cn.edu.neusoft.wuguangsheng.flowerimpression.bean.UserInfoBean;
import cn.edu.neusoft.wuguangsheng.flowerimpression.listener.TListener;
import cn.edu.neusoft.wuguangsheng.flowerimpression.model.UserInfoModel;

public class SetUserActivity extends BaseActivity implements View.OnClickListener {
    TextView get_user_phone;
    TextView get_user_email;
    String phone;
    String email;
    ImageView setuser_fh;
    private boolean up = false;

    LinearLayout info_setuserinfo;
    LinearLayout setuser_setpassword;
    LinearLayout setuser_setemail;
    LinearLayout setuser_setphone;
    LinearLayout info_qlhc;
    @Override
    void initView() {
        setLayout_file(R.layout.activity_set_user);
        get_user_phone = (TextView)findViewById(R.id.get_user_phone);
        get_user_email = (TextView)findViewById(R.id.get_user_email);
        info_setuserinfo = (LinearLayout)findViewById(R.id.info_setuserinfo);
        setuser_fh = (ImageView)findViewById(R.id.setuser_fh);
        setuser_setpassword = (LinearLayout)findViewById(R.id.setuser_setpassword);

        setuser_setemail = (LinearLayout)findViewById(R.id.setuser_setemail);
        setuser_setphone = (LinearLayout)findViewById(R.id.setuser_setphone);
        info_qlhc = (LinearLayout)findViewById(R.id.info_qlhc);

//        phone = getIntent().getStringExtra("phone");
//        email = getIntent().getStringExtra("email");
        UserInfoModel userInfoModel = new UserInfoModel();
        userInfoModel.getUserInfo(getid(), new TListener<UserInfoBean>() {
            @Override
            public void onResponse(UserInfoBean userInfoBean) {
                phone = userInfoBean.getUser_phone();
                email = userInfoBean.getUser_email();
                get_user_phone.setText(phone);
                if (email == null){
                    get_user_email.setText("请添加你的邮箱");
                }
                else{
                    get_user_email.setText(email);
                }
            }

            @Override
            public void onFail(String msg) {

            }
        });





    }

    @Override
    void initEvent() {
        info_setuserinfo.setOnClickListener(this);
        setuser_fh.setOnClickListener(this);
        setuser_setpassword.setOnClickListener(this);

        setuser_setemail.setOnClickListener(this);
        setuser_setphone.setOnClickListener(this);
        info_qlhc.setOnClickListener(this);
    }

    @Override
    void initDate() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.info_setuserinfo:
                Intent intent = new Intent(SetUserActivity.this,SetUserInfoActivity.class);
                startActivity(intent);
                break;
            case R.id.setuser_fh:
                finish();
                break;
            case R.id.setuser_setpassword:
                Intent intent1 = new Intent(SetUserActivity.this,SetPasswordActivity.class);
                startActivity(intent1);
                break;
            case R.id.setuser_setemail:
                Intent intent2 = new Intent(SetUserActivity.this,SetEmailActivity.class);
                startActivity(intent2);
                break;
            case R.id.setuser_setphone:
                Intent intent3 = new Intent(SetUserActivity.this,SetPhoneActivity.class);
                startActivity(intent3);
                break;
            case R.id.info_qlhc:
                Intent intent4 = new Intent(SetUserActivity.this,DemoTextActivity.class);
                startActivity(intent4);
                break;
        }

    }

    @Override
    protected void onPause() {
        super.onPause();
        up = true;

    }

    @Override
    protected void onResume() {
        super.onResume();
        if (up) {
            initView();
            initEvent();
            initDate();
            up = false;
        }
    }
}
